package cn.javaxc.mvcwork.util.common;

import org.apache.log4j.Logger;
import cn.javaxc.mvcwork.controller.MVCConfig;
/**
 *  Fumine的日志类,记录测试输出
 */
public class FrameLog 
{ 
	private static Logger log = Logger.getLogger(FrameLog.class);	
	public static Logger getLog(){
		return log;
	}
	private static String getWebContext(){
		if (MVCConfig.getConfig()!=null){
			return MVCConfig.getWebContext();
		}
		return "";
	}
	public static void info(String s){
		log.info(getWebContext()+" "+s);		
	}
	public static void info(Object obj,String s){		
		log.info(getWebContext()+" "+obj.getClass().getName()+" "+s);
	}
	public static void info(String obj,Exception ex){		
		log.info(getWebContext()+" "+obj,ex);
	}
	public static void debug(String s){		
		log.debug(getWebContext()+" "+s);
	}
	public static void debug(Object obj,String s){		
		log.debug(getWebContext()+" "+obj.getClass().getName()+" "+s);
	}
	public static void error(String s){		
		log.error(getWebContext()+" "+s);
	}
	public static void error(String obj,Exception ex){		
//			log.error(getWebContext()+" "+obj,ex);
		try{
			log.error(getWebContext()+" "+new String(obj.getBytes("UTF-8"),"GBK"),ex);
		}catch(java.io.UnsupportedEncodingException e){

		}
	}
	public static void error(Class obj,Exception ex){		
		log.error(getWebContext()+" "+obj.getName(),ex);
	}
	public static void warn(String s){		
		log.warn(getWebContext()+" "+s);
	}
	public static void trace(String s){		

	}
}
